<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <link
            rel="stylesheet"
            href="https://static.web.sdo.com/chuanshi/common/style/bootstrap.min.css"
        />
        <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.7.3/axios.min.js"></script>
        <title>登录</title>
        <style>
            .wrapper {
                position: relative;
                width: 100vw;
                height: 100vh;
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                background-color: #ddd;
            }
            .box {
                width: 360px;
                padding: 30px 30px 40px 30px;
                background-color: #fff;
                box-shadow: 1px 1px 12px rgba(0, 0, 0, 0.6);
            }
            img {
                display: block;
                width: 50px;
                margin: 0px auto 20px auto;
            }
        </style>
    </head>
    <body>
        <div class="wrapper">
            <div class="box">
                <img src="/static/assets/logo.png" alt="" />
                <div class="form-group">
                    <input
                        type="text"
                        class="form-control username"
                        placeholder="请输入用户名"
                    />
                </div>
                <div class="form-group">
                    <input
                        type="text"
                        class="form-control password"
                        placeholder="请输入密码"
                    />
                </div>
                <div class="btn btn-block btn-primary">登录</div>
            </div>
        </div>
    </body>
</html>
<script>
    const username = document.querySelector(".username");
    const password = document.querySelector(".password");
    const btn = document.querySelector(".btn");
    btn.addEventListener("click", async () => {
        console.log(username.value, password.value);
        if (username.value && password.value) {
            const res = await axios.post("/api/account/login", {
                username: username.value,
                password: password.value,
            });
            if (res.data.data) {
                window.location.href = "/";
            }
        }
    });
</script>
